﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace FrogEngine
{
	public abstract class FSMState : IFSMState
	{
		public FSMState(string stateName)
		{
			this.stateName = stateName;
			transitions = new Dictionary<string, IFSMState>();
		}

		private string stateName;
		public string StateName
		{
			get { return stateName; }
		}

		private Dictionary<string, IFSMState> transitions;
		public IDictionary<string, IFSMState> Transitions
		{
			get { return transitions; }
		}

		public void AddTransition(IFSMState state)
		{
			if (!transitions.ContainsKey(state.StateName))
				transitions.Add(state.StateName, state);
		}

		public void RemoveTransition(IFSMState state)
		{
			if (transitions.ContainsKey(state.StateName))
				transitions.Remove(state.StateName);
		}

		public bool IsValidTransition(IFSMState nextState)
		{
			return transitions.ContainsKey(nextState.StateName);
		}

		public abstract void OnLeaving();

		public abstract void OnEntering();

		public abstract void Update(GameTime gameTime);
	}
}
